#ifndef _BLUETOOTH_SERIAL_H_
#define _BLUETOOTH_SERIAL_H_

#include <stdbool.h>
#include "esp_err.h"
#include "esp_spp_api.h"

#define ESP32_HAL_BT_DEBUG 0

#if ESP32_HAL_BT_DEBUG
#define log_v(...) printf(__VA_ARGS__)
#define log_d(...) printf(__VA_ARGS__)
#define log_i(...) printf(__VA_ARGS__)
#define log_w(...) printf(__VA_ARGS__)
#define log_e(...) printf(__VA_ARGS__)
#define log_n(...) printf(__VA_ARGS__)
#else
#define log_v(...) 
#define log_d(...) 
#define log_i(...) 
#define log_w(...) 
#define log_e(...) 
#define log_n(...) 
#endif


typedef void(*bt_serial_data_cb)(const uint8_t *buffer, size_t size);
typedef void(*confirm_request_cb)(uint32_t num_val);
typedef void(*auth_complete_cb)(bool success);


void bt_serial_stop(void);
bool bt_serial_begin(char* localName, bool isMaster);
int bt_serial_available(void);
int bt_serial_peek(void);
bool bt_serial_has_client(void);
int bt_serial_read(void);
size_t bt_serial_putchar(uint8_t c);
size_t bt_serial_write(const uint8_t *buffer, size_t size);
void bt_serial_flush(void);
void bt_serial_end(void);
void bt_serial_on_confirm_request(confirm_request_cb cb);
esp_err_t bt_serial_register_callback(esp_spp_cb_t * callback);

void bt_serial_confirm_reply(bool confirm);
void bt_serial_on_auth_complete(auth_complete_cb cb);

void bt_serial_enable_spp(void);
bool bt_serial_set_pin(const char *pin);
bool bt_serial_connect_by_name(char* remoteName);
bool bt_serial_connect_by_addr(uint8_t remoteAddress[]);
bool bt_serial_connect(void);
bool bt_serial_connected(int timeout);
bool bt_serial_is_ready(bool checkMaster, int timeout) ;
bool bt_serial_disconnect(void);
bool bt_serial_unpair_device(uint8_t remoteAddress[]);

#endif

